package ph.com.gs3.formalistics;

import ph.com.gs3.formalistics.communicators.AuthenticationCommunicatorModule;
import ph.com.gs3.formalistics.communicators.Communicator;
import ph.com.gs3.formalistics.managers.SessionManager;
import ph.com.gs3.formalistics.model.dao.UserAccountsDAO;
import ph.com.gs3.formalistics.utilities.FLLogger;
import android.app.Application;

public class MainApplication extends Application {

	@Override
	public void onCreate() {
		super.onCreate();

		initializeSingletons();
		FLLogger.setMode(FLLogger.MODE_DEVELOPMENT);
		// FLLogger.setMode(FLLogger.MODE_PRODUCTION);
	}

	private void initializeSingletons() {

		// initialize communicator dependent managers

		Communicator communicator = new Communicator();
		AuthenticationCommunicatorModule authCommModule = new AuthenticationCommunicatorModule(
		        communicator);

		UserAccountsDAO userAccountsDAO = new UserAccountsDAO(getApplicationContext());

		SessionManager sessionManager = SessionManager.createApplicationInstance(
		        getApplicationContext(), userAccountsDAO, authCommModule);

		sessionManager.startListeningToNetworkChanges();

	}

}
